//
// Presenter.ts
// Author:qiuchun(362460803@qq.com)
// Time:2023.05.03 01:44:28
// Desc:控制器父类

import Facade from "./Facade";
import Notifier from "./Notifier";
import Proxy from "./Proxy";

export class Presenter extends Notifier {

    constructor() {
        super();
    }

    //调用数据模型
    public getProxy(name: string): Proxy | undefined {

        return Facade.getInstance().retrieveProxy(name);
    }

    //调用其他presenter，也可以发消息通知
    public getPresenter(name: string): Presenter | undefined {

        return Facade.getInstance().retrievePresenter(name);
    }

    //不提倡，应该用发消息代替
    public getMediator(name: string) {
        console.warn("不提倡使用此方法，通过事件与Mediator联系！因为调用者不清楚目标Mediator是否存在。")
        return undefined;
    }

    //给Mediator广播消息,不提倡给presenter发，消息事件上应提醒。
    sendNotification(name: string, body?: object, type?: string, dest?: Notifier | string) {
        Facade.getInstance().sendNotification(name, body, type, dest);
    };





}


